﻿var pagesComm = {
	search: function() {
		var searchForm = $("#search_form"),
		input = $("#search-input"),
		submitSite = $("#search-btn"),
		str = encodeURI($.trim(input.attr('value'))),
		searchUrl = function(str) {
			return 'http://search.microsoft.com/zh-cn/results.aspx?q=' + str + '&x=0&y=0';
		};
		input.on('keyup',
		function() {
			str = encodeURI($.trim($(this).attr('value')));
		});
		searchForm.on('submit',
		function() {
			if (str) {
				location.href = searchUrl(str);
				return false;
			} else {
				return false;
			}
		});
		submitSite.on('click',
		function() {
			if (str) {
				location.href = searchUrl(str);
			} else {
				return false;
			}
		});
	}
}
$(function() {
	pagesComm.search();
}) 

